package net.xo68.destiny.contract.enums.job;

/**
 * 任务实例状态枚举
 * @author wuxie
 * @version 2020-12-28
 */
public enum JobInstanceStateEnum {
    /**
     * 初始化
     */
    INIT((byte)0),
    /**
     * 调度成功
     */
    SCHED_SUCCESS((byte)1),
    /**
     * 调度失败
     */
    SCHED_FAIL((byte)2),
    /**
     * 处理成功
     */
    HANDLE_SUCCESS((byte)3),
    /**
     * 处理失败
     */
    HANDLE_FAIL((byte)4);


    private final Byte code;

    JobInstanceStateEnum(Byte code) {
        this.code = code;
    }

    public Byte getCode() {
        return code;
    }

    public static JobInstanceStateEnum of(int code){
        for (JobInstanceStateEnum jobInstanceStateEnum: JobInstanceStateEnum.values()){
            if(code == jobInstanceStateEnum.getCode()){
                return jobInstanceStateEnum;
            }
        }
        return JobInstanceStateEnum.INIT;
    }
}
